package com.example.ui_view.frame;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.example.ui_view.R;

public class FrameDemeActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {
    private RadioGroup rg_barton;
    private wxFragment wxFragment = null;
    private txlFragment txlFragment = null;
    private fxFragment fxFragment = null;
    private wdFragment wdFragment = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_frame_deme);
        rg_barton = findViewById(R.id.rg_barton);
        rg_barton.setOnCheckedChangeListener(this);

    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        if(checkedId == R.id.rb_wx){
            if(wxFragment==null){
                wxFragment = new wxFragment();
            }
            transaction.replace(R.id.fl_inter,wxFragment);
        }
        if(checkedId == R.id.rb_txl){
            if(txlFragment==null){
                txlFragment = new txlFragment();
            }
            transaction.replace(R.id.fl_inter,txlFragment);
        }
        if(checkedId == R.id.rb_fx){
            if(fxFragment==null){
                fxFragment = new fxFragment();
            }
            transaction.replace(R.id.fl_inter,fxFragment);
        }
        if(checkedId == R.id.rb_wd){
            if(wdFragment==null){
                wdFragment = new wdFragment();
            }
            transaction.replace(R.id.fl_inter,wdFragment);
        }
        transaction.commit();
    }
}
